import { SettingsInterface, SettingsActionInterface } from '#/store.settings'

const userState: SettingsInterface = {
  collapsed: false,
  theme: 'light'
}

const settingsReducer = (state: SettingsInterface = userState, action: SettingsActionInterface) => {
  const { type, payload } = action
  switch (type) {
    case 'updateCollapsed':
      return { ...state, collapsed: payload?.collapsed }
    case 'updateTheme':
      return { ...state, theme: payload?.theme }
    default:
      return state
  }
}

export default settingsReducer
